<?php

/**
 * Sample formatter for tests
 *
 * PHP version 5
 *
 * @category  Stream
 * @package   Stream_Iterate
 * @author    Philippe Jausions <jausions@php.net>
 * @copyright 2008 by 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD
 * @link      http://pear.11abacus.com/package/Stream_Iterate
 */

require_once 'Stream/Iterate/FormatterInterface.php';

/**
 * Test formatter
 *
 * @category  Stream
 * @package   Stream_Iterate
 * @author    Philippe Jausions <jausions@php.net>
 * @copyright 2008 by 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD
 * @link      http://pear.11abacus.com/package/Stream_Iterate
 */
class MyTestFormat implements Stream_Iterate_FormatterInterface
{
    /**
     * Called on first iteration
     *
     * @param mixed $data Data
     *
     * @return string
     */
    function onFirstIteration($data)
    {
        echo "First Iteration\n";
    }

    /**
     * Called to format data to string
     *
     * @param mixed   $key       Key of iteration
     * @param mixed   $value     Value of iteration
     * @param integer $iteration Iteration count
     *
     * @return string
     */
    function formatKeyPair($key, $value, $iteration)
    {
        echo $iteration.") KEY: ".$key."; VALUE: ".$value."\n";
    }

    /**
     * Called on last iteration
     *
     * @param integer $iteration Iteration count
     *
     * @return string
     */
    function onLastIteration($iteration)
    {
        echo "Last Iteration: #".$iteration."\n";
    }
}

?>
